package com.andnnl.date;

import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.util.RandomUtil;

/**
 * Created by chenss on 2025/1/10.
 */
public class TimeIntervalTest {
    public static void main(String[] args) throws InterruptedException {

        test_1();
        test_group();
    }
    private static void test_1() throws InterruptedException {
        TimeInterval timeInterval = new TimeInterval();
        for (int i = 0; i < 10; i++) {
            System.out.println(i+" "+timeInterval.intervalRestart());
            Thread.sleep(RandomUtil.randomInt(1000));

        }
        System.out.println("total:"+timeInterval.interval());
    }
    private static void test_group() throws InterruptedException {
        TimeInterval timeInterval = new TimeInterval();
        timeInterval.start("test");
        for (int i = 0; i < 10; i++) {
            System.out.println(i+" group "+timeInterval.intervalRestart("test"));
            Thread.sleep(RandomUtil.randomInt(1000));
            System.out.println("total 2:"+timeInterval.interval());
        }
        System.out.println("total:"+timeInterval.interval());
    }
}
